package com.feinno.urcs.group.entity;

import com.feinno.superpojo.SuperPojo;
import com.feinno.superpojo.annotation.Field;
import com.feinno.urcs.types.MobileNo;

/**
 * 群成员信息, 由GroupDao读取
 *
 * @author Li.Hongbo <lihongbo@feinno.com>
 */
public class GroupMember extends SuperPojo {
	@Field(id = 1)
	private MobileNo mobileNo;

	@Field(id = 2)
	private int identity;

	@Field(id = 3)
	private GroupMemberStatus status;

	@Field(id = 4)
	private String displayname;

	@Field(id = 5)
	private String etype;

	@Field(id = 6)
	private MobileNo referBy;

	public String getEtype() {
		return etype;
	}

	public void setEtype(String etype) {
		this.etype = etype;
	}

	public MobileNo getMobileNo() {
		return mobileNo;
	}

	public void setMobileNo(MobileNo mobileNo) {
		this.mobileNo = mobileNo;
	}

	public GroupMemberRole getRole() {
		//
		//TODO 目前这么写应该没啥问题, 但是当与飞信互通后会有问题,飞信群状态太多...
		switch (getIdentity()) {
			case 1:
				return GroupMemberRole.CHAIRMAN;
			case 3:
				return GroupMemberRole.PARTICIPANT;
			case 61:
				return null;
			default:
				return GroupMemberRole.PARTICIPANT;
		}
	}


	public String getDisplayname() {
		return displayname;
	}

	public void setDisplayname(String displayname) {
		this.displayname = displayname;
	}

	public int getIdentity() {
		return identity;
	}

	public void setIdentity(int identity) {
		//TODO 这个地方需要梳理一下, 两个状态写在一个字段...
		this.identity = identity;
		if (identity == 61) {
			setStatus(GroupMemberStatus.PENDING);
		} else {
			setStatus(GroupMemberStatus.CONNECTED);
		}

	}

	public GroupMemberStatus getStatus() {
		return status;
	}

	public void setStatus(GroupMemberStatus status) {
		this.status = status;
	}

	public MobileNo getReferBy() {
		return referBy;
	}

	public void setReferBy(MobileNo referBy) {
		this.referBy = referBy;
	}
}
